package com.yang.config;

import com.yang.filter.LoginCheckFilter;
import com.yang.interceptor.DemoInterceptor;
import com.yang.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration //配置类
public class WebConfig implements WebMvcConfigurer {

//    @Resource(name = "demoInterceptor")
//    private DemoInterceptor demoInterceptor;

    @Resource(name = "loginCheckInterceptor")
    private LoginCheckInterceptor loginCheckInterceptor;

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) { //注册 配置拦截器
//        registry.addInterceptor(demoInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
//    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) { //注册 配置拦截器
        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**").excludePathPatterns("/login");
    }
}
